package com.pt5.pthouduan.entity;

import com.pt5.pthouduan.mapper.TorrentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class PromotionScheduler {

    @Autowired
    private TorrentMapper torrentMapper;

    /**
     * 每天凌晨 2 点执行
     */
    @Scheduled(cron = "0 0 2 * * ?")
    public void updateTorrentPromotions() {
        torrentMapper.setFreePromotion();
        torrentMapper.setDoubleUpload();
        torrentMapper.setHalfDownload();
        torrentMapper.clearPromotion();
        System.out.println("[促销任务] 执行完成：" + LocalDateTime.now());
    }
}
